--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_kurodani_yamame = General:new(extension, "hy_kurodani_yamame", "chi_k", 4, 4, General.Female)

    local weave_web = fk.CreateSkill {
        name = "weave_web",
    }
    weave_web:addEffect(fk.CardEffectCancelledOut, {
        times = function(self, player)
            return 2 - player:usedSkillTimes(weave_web.name, Player.HistoryRound)
        end,
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(weave_web.name) and data.card.trueName == "slash" and data.to ~= player and
                (player:usedSkillTimes(weave_web.name, Player.HistoryRound) < 2 or player.room.current == player)
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            if player.hp > 2 then
                return room:askToSkillInvoke(player, {
                    skill_name = weave_web.name,
                    prompt = "weave_web_prompt1::" .. data.to.id
                })
            elseif player.hp <= 2 then
                return room:askToSkillInvoke(player, {
                    skill_name = weave_web.name,
                    prompt = "weave_web_prompt2::" .. data.to.id
                })
            end
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            if player.hp > 2 then
                room:useCard({
                    from = player,
                    tos = { data.to },
                    card = Fk:cloneCard("stab__slash"),
                    extra_data = {
                        weave_web = player,
                    }
                })
            elseif player.hp <= 2 then
                room:useCard({
                    from = player,
                    tos = { data.to },
                    card = Fk:cloneCard("slash"),
                    unoffsetableList = room:getAllPlayers()
                })
            end
            if room.current == player then
                player:addSkillUseHistory(weave_web.name, -1)
            end
        end
    })
    weave_web:addEffect(fk.TargetSpecified, {
        can_refresh = function(self, event, target, player, data)
            return (data.extra_data or {}).weave_web == player
        end,
        on_refresh = function(self, event, target, player, data)
            data.to:addQinggangTag(data)
        end
    })

    local miasma_imprison = fk.CreateSkill {
        name = "miasma_imprison",
    }
    miasma_imprison:addEffect(fk.AfterCardsMove, {
        can_trigger = function(self, event, target, player, data)
            local targets = {}
            for _, move in ipairs(data) do
                if move.to and move.to ~= player and move.toArea == Card.PlayerHand and player.room.current ~= move.to then
                    if player.hp > 2 and #move.to:getCardIds("h") > move.to:getMaxCards() and #move.to:getCardIds("h") > 0 then
                        table.insertIfNeed(targets, move.to)
                    elseif player.hp <= 2 and not move.to:isNude() then
                        table.insertIfNeed(targets, move.to)
                    end
                end
            end
            if #targets > 0 then
                event:setCostData(self, targets)
            end
            return player:hasSkill(miasma_imprison.name) and player.room.current.phase ~= Player.NotActive and #targets > 0
        end,
        on_trigger = function(self, event, target, player, data)
            local targets = event:getCostData(self)
            for _, t in ipairs(targets) do
                if player:getMark("@@miasma_imprison_prohibit-turn") == 0 then
                    event:setCostData(self, t)
                    self:doCost(event, target, player, data)
                end
            end
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            local target = event:getCostData(self)
            if player.hp > 2 then
                return room:askToSkillInvoke(player, {
                    skill_name = miasma_imprison.name,
                    prompt = "miasma_imprison_prompt1::" .. target.id
                })
            elseif player.hp <= 2 then
                return room:askToSkillInvoke(player, {
                    skill_name = miasma_imprison.name,
                    prompt = "miasma_imprison_prompt2::" .. target.id
                })
            end
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local target = event:getCostData(self)
            if player.hp > 2 then
                room:askToDiscard(target, {
                    skill_name = miasma_imprison.name,
                    min_num = 1,
                    max_num = 1,
                })
            elseif player.hp <= 2 then
                local cards = room:askToChooseCards(player, {
                    skill_name = miasma_imprison.name,
                    target = target,
                    min = 1,
                    max = 2,
                    flag = "he",
                })
                room:obtainCard(player, cards, false, fk.ReasonPrey, player, miasma_imprison.name)
                room:setPlayerMark(player, "@@miasma_imprison_prohibit-turn", 1)
            end
        end
    })

    extension:loadSkillSkels { weave_web, miasma_imprison }
    hy_kurodani_yamame:addSkills { "weave_web", "miasma_imprison" }

    Fk:loadTranslationTable {
        ["hy_kurodani_yamame"] = "黑谷山女",
        ["#hy_kurodani_yamame"] = "刺花之影",
        ["illustrator:hy_kurodani_yamame"] = "鈴木アイリ",
        ["designer:hy_kurodani_yamame"] = "黑曜人形",
        ["cv:hy_kurodani_yamame"] = "",

        ["weave_web"] = "罗网",
        [":weave_web"] = "每轮限两次（你的回合内不计次数），对其他角色使用的【杀】被抵消后，若你的体力值大于/不大于2，你可以视为对其使用一张无视防具的刺【杀】/不可被响应的【杀】。",
        ["weave_web_prompt1"] = "罗网：你可以视为对%dest使用一张无视防具的刺【杀】",
        ["weave_web_prompt2"] = "罗网：你可以视为对%dest使用一张不可被响应的【杀】",

        ["miasma_imprison"] = "瘴缚",
        [":miasma_imprison"] = "其他角色于其回合外获得手牌后，若你的体力值大于2且其手牌数大于其手牌上限/你的体力值不大于2，你可以令其弃置一张手牌/获得其至多两张牌并令你本回合不能再发动“瘴缚”。",
        ["miasma_imprison_prompt1"] = "瘴缚：你可以令%dest弃置一张手牌",
        ["miasma_imprison_prompt2"] = "瘴缚：你可以获得%dest至多两张牌",
        ["@@miasma_imprison_prohibit-turn"] = "瘴缚禁止"
    }
end
